<?php
session_start();

function logToFile($msg, $filename="test.log") {
	$fd = fopen($filename, "a"); 
	$str = "[" . date("Y/m/d h:i:s", mktime()) . "] " . $msg;
	 fwrite($fd, $str . "\n"); 
	 fclose($fd);
} 




function isCalendarReadOnly(){
	if(getPostOrGetParam("userid") == $_SESSION['logged_userid'])
		echo 'false';
	else
		echo 'true';
// 	echo "userid: ".getPostOrGetParam("userid").', logged_userid: '.$_SESSION['logged_userid'];
}

/*
function getPostOrGetParam($param){
	logToFile("getPostOrGetParam: "+$param);
	if(isset($_POST[$param]))
		return $_POST[$param];
	else{
		if(isset($_GET[$param]))
			return $_GET[$param];
		else
			return "";
	}
}*/

function getTime($data){
	
	list ($date, $time) = split ('[ ]', $data);
	
	echo "date>>".$date."<<time>>".$time."<<";
	
	//return $time;
	
}

function compareTime($timeA, $timeB){
// 	15:00
// returns 0 if igual, 1 if A greater than B, and -1 if B greater than A

	if($timeA == $timeB){
		return 0;
	}
	
	list ($hour, $minutes) = split ('[:]', $timeA);
	$hourA = $hour;
	$minutesA = $minutes;
	list ($hour, $minutes) = split ('[:]', $timeB);
	$hourB = $hour;
	$minutesB = $minutes;
	
	if($hourA > $hourB){
		return 1;
	}else if($hourA < $hourB){
		return -1;
	}else if($hourA == $hourB){
		if($minutesA > $minutesB){
			return 1;
		}else if($minutesA < $minutesB){
			return -1;
		}else if($minutesA == $minutesB){
			return 0;
		}
	}
		
	
}

?>